﻿using BBCore.Core.Models.BaseModels;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BBCore.Application.Admins
{
    public class TempService : ITempService
    {
        private readonly IFreeSql FreeSql;
        public TempService(IFreeSql freeSql)
        {
            FreeSql = freeSql;

        }
        public async Task<DataTable> GetFqlToDtAsync(string sql)
        {
            return await FreeSql.Select<object>().WithSql(sql).ToDataTableAsync("*");
        }

     

        public async Task<List<ControlDetails>> GetControlDetailsListByIdAsync(int authid)
        {
            return await FreeSql.Select<ControlDetails>().Where(a => a.Menu_AuthId == authid).ToListAsync();
        }
        public async Task Add_ControlDetailsAsync(ControlDetails controlDetails)
        {
            var repo = FreeSql.GetRepository<ControlDetails>();
            await repo.InsertAsync(controlDetails);
        }

        public async Task Update_ControlDetailsAsync(ControlDetails controlDetails)
        {
            await FreeSql.Update<ControlDetails>().SetSource(controlDetails).ExecuteAffrowsAsync();
        }

        public async Task Remove_ControlDetailsAsync(IEnumerable<ControlDetails> controlDetails)
        {
            await FreeSql.GetRepository<ControlDetails>().DeleteAsync(controlDetails);
        }

        
    }
}
